$(function() {
		console.log("document ready ...");
		getInfo();
	});
var resumeid = "";
var basePath = "";
function getInfo() {
	var location = (window.location+'').split('/'); 
	basePath = location[0]+'//'+location[2]+'/'+location[3]; 
	console.log(basePath);
	$.ajax({
		type : 'POST',
		data : {
		},
		url : basePath + '/user/getResumeInfoNotId',
		dataType : 'json',
		success : function(result) {
			console.log("success");
			var model = result.model;
			if (model.code == 0) {
				console.log(model.msg);
				resumeid = model.resume.resumeId;
				resume = model.resume;
				$("#name").val(resume.name);
				$("#topDegree").val(resume.educationalBackground);
				$("#tel").val(resume.telephoneNum);
				$("#email").val(resume.email);
				$("#currentState").val(resume.currentStatusDesc);
				
				$("#expectCity").val(resume.desiredLocationDesc);
				$("#expectPosition").val(resume.desiredWorkDesc);
				$("#expectSalary").val(resume.desiredSalayDesc);
				
				var start = null;
				var end = null;
				var we = model.we;
				if(null != we && ""!=we){
					start = new Date(we.startTime);
					end = new Date(we.endTime);
					$("#companyYearStart").val(start.getFullYear());
					$("#companyYearEnd").val(end.getFullYear());
					$("#companyMonthStart").val(start.getMonth()+1);
					$("#companyMonthEnd").val(end.getMonth()+1);
				}
				$("#companyName").val(we.company);
				$("#positionName").val(we.duty);
				
				var pe = model.pe;
				if(null != pe && ""!=pe){
					start = new Date(pe.startTime);
					end = new Date(pe.endTime);
					$("#projectYearStart").val(start.getFullYear());
					$("#projectYearEnd").val(end.getFullYear());
					$("#projectMonthStart").val(start.getMonth()+1);
					$("#projectMonthEnd").val(end.getMonth()+1);
				}
				$("#projectName").val(pe.name);
				$("#thePost").val(pe.duty);
				$("#projectDescription").val(pe.rDescribe);
				
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		}
	});

}

function basicInfo() {
	var name = $("#name").val();
	var topDegree = $("#topDegree").val();
	var tel = $("#tel").val();
	var email = $("#email").val();
	var currentState = $("#currentState").val();
	
	$("#basicInfo").ajaxSubmit({
			type : 'post',
			url : basePath +'/user/basicInfo',
			dataType : "json",
			data : {
				resumeid : resumeid,
				topDegree : topDegree,
				tel : tel,
				name : name,
				email : email,
				currentState : currentState
			},
			success : function(result) {
				var model = result.model;
				console.log("提交成功");
				if (model.code == 0) {
					console.log(model.msg);
					resumeid = model.resume.resumeId;
					alert("成功完善基本信息");
				} else {
					alert(model.msg);
					console.log(model.msg);
				}

			},
			error : function(result) {
				alert("系统异常");
			}
		});
	return false; // 阻止表单自动提交事件
}

function expectInfo() {
	var expectCity = $("#expectCity").val();
	var expectPosition = $("#expectPosition").val();
	var expectSalary = $("#expectSalary").val();

/*expectCity : expectCity,
	expectPosition : expectPosition,
	expectSalary : expectSalary
*/
	$("#expectForm").ajaxSubmit({
		type : 'post',
		url : basePath +'/user/expectInfo',
		dataType : "json",
		data : {
			resumeid : resumeid
		},
		success : function(result) {
			var model = result.model;
			console.log("提交成功");
			if (model.code == 0) {
				console.log(model.msg);
				alert("更新成功");
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		},
		error : function(result) {
			alert("系统异常");
		}
	});
	return false; // 阻止表单自动提交事件
}

function experienceInfo() {
	var companyName = $("#companyName").val();
	var positionName = $("#positionName").val();
	var companyYearStart = $("#companyYearStart").val();
	var companyYearEnd = $("#companyYearEnd").val();
	var companyMonthStart = $("#companyMonthStart").val();
	var companyMonthEnd = $("#companyMonthEnd").val();
	
	/*companyName : companyName,
	positionName : positionName,
	companyYearStart : companyYearStart,
	companyYearEnd : companyYearEnd,
	companyMonthStart : companyMonthStart,
	companyMonthEnd : companyMonthEnd*/
	$("#experienceForm").ajaxSubmit({
		type : 'post',
		url : basePath +'/user/experienceInfo',
		dataType : "json",
		data : {
			resumeid : resumeid
		},
		success : function(result) {
			var model = result.model;
			console.log("提交成功");
			if (model.code == 0) {
				console.log(model.msg);
				alert("更新成功");
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		},
		error : function(result) {
			alert("系统异常");
		}
	});
	return false; // 阻止表单自动提交事件
}

function projectInfo() {
	var projectName = $("#projectName").val();
	var thePost = $("#thePost").val();
	var projectYearStart = $("#projectYearStart").val();
	var projectYearEnd = $("#projectYearEnd").val();
	var projectMonthStart = $("#projectMonthStart").val();
	var projectMonthEnd = $("#projectMonthEnd").val();
	var projectDescription = $("#projectDescription").val();
	
	/*companyName : companyName,
	positionName : positionName,
	companyYearStart : companyYearStart,
	companyYearEnd : companyYearEnd,
	companyMonthStart : companyMonthStart,
	companyMonthEnd : companyMonthEnd*/
	$("#projectForm").ajaxSubmit({
		type : 'post',
		url : basePath +'/user/projectInfo',
		dataType : "json",
		data : {
			resumeid : resumeid
		},
		success : function(result) {
			var model = result.model;
			console.log("提交成功");
			if (model.code == 0) {
				console.log(model.msg);
				alert("更新成功");
			} else {
				alert(model.msg);
				console.log(model.msg);
			}
		},
		error : function(result) {
			alert("系统异常");
		}
	});
	return false; // 阻止表单自动提交事件
}